using System;
using Kopernikus.Collections.Generic;

namespace Kopernikus.Parsing
{
    public class GrammarBuilder
    {
        private readonly Set<Production> m_productions = new Set<Production>();
        private readonly Set<Production> m_startProductions = new Set<Production>();

        public Set<Production> StartProductions
        {
            get { return m_startProductions; }
        }

        public Set<Production> Productions
        {
            get { return m_productions; }
        }

        public Grammar CreateGrammar()
        {
            if (StartProductions.Count == 0)
            {
                throw new InvalidOperationException("StartProductions must be defined before creating grammar.");
            }
            return new Grammar(StartProductions, Productions);
        }
    }
}